package com.hdu.dwh.controller;

import org.springframework.web.bind.annotation.RestController;

import com.hdu.dwh.results.ResponseResult;
import com.hdu.dwh.service.flink_service.FlinkWebRestService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;





@RestController
@RequestMapping("/flink-web-rest")
@Slf4j
@Tag(name="FlinkWeb管理", description = "FlinkWeb管理相关接口")
public class FlinkWebRestController {
    @Autowired
    private FlinkWebRestService flinkWebRestService;


    @Operation(summary ="获取当前Flink任务列表")
    @GetMapping("fetchFlinkCurrentJob")
    public ResponseResult<Object> fetchFlinkCurrentJob() {
        Object flinkJobList = flinkWebRestService.fetchFlinkCurrentJob();
        return ResponseResult.success("获取当前Flink任务列表成功", flinkJobList);
    }

    @Operation(summary ="获取指定Flink任务详情")
    @GetMapping("fetchFlinkJobDetails/{jobId}")
    public ResponseResult<Object> fetchFlinkJobDetails(@PathVariable String jobId) {
        return ResponseResult.success(flinkWebRestService.fetchFlinkJobDetails(jobId));
    }

    @Operation(summary ="停止指定Flink任务")
    @PatchMapping("stopFlinkJob/{jobId}")
    public ResponseResult<Object> stopFlinkJob(@PathVariable String jobId) {
        return ResponseResult.success(flinkWebRestService.stopFlinkJob(jobId));
    }

    @Operation(summary ="获取Flink已上传的JAR包列表")
    @GetMapping("fetchFlinkUploadJars")
    public ResponseResult<Object> fetchFlinkUploadJars() {
        return ResponseResult.success(flinkWebRestService.fetchFlinkUploadJars());
    }
    
    
    
    
}
